var status = -1;
var selectionLog = [];

function start() {
    action(1, 0, 0)
}

function action(mode, type, selection) {
    var reactor = "action" + (im.getNumberFromQuestInfo(58819, "letter") % 3);
    eval(reactor)(mode, type, selection)
}

function action0(d, c, b) {
    if (status == 0 && d == 0) {
        im.dispose();
        return
    }(d == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            var e = im.getItemId();
            im.gainItem(e, -1);
            im.curNodeEventEnd(true);
            im.eventSKill(0);
            im.setInGameDirectionMode(true, true, true);
            im.inGameDirectionEvent_SetHideEffect(1);
            im.fieldEffect_InsertCanvas(1, 200, 0, 0, 0, 1300, 0);
            im.inGameDirectionEvent_AskAnswerTime(1600)
        } else {
            if (status === a++) {
                im.inGameDirectionEvent_Monologue("我把来找我的棘鬼赶走了。生怕被人们看见他跟我来往……", 0)
            } else {
                if (status === a++) {
                    im.inGameDirectionEvent_Monologue("看见棘鬼和人类和睦相处……我也觉得很开心。", 1)
                } else {
                    if (status === a++) {
                        im.addPopupSay(9111062, 1000, "……我之前不明白哥的心意，还埋怨过他。", "", 0);
                        im.addNumberForQuestInfo(58819, "letter", 1);
                        im.addNumberForQuestInfo(58710, "2", 3);
                        im.getTopMsgFont("棘鬼记住了你的话。", 3, 20, 8, 0, 0);
                        im.fieldEffect_InsertCanvas(0, 0, 0, 0, 0, 1300, 0);
                        im.inGameDirectionEvent_AskAnswerTime(1600)
                    } else {
                        if (status === a++) {
                            im.eventSKill(0);
                            im.setInGameDirectionMode(false, true, false);
                            im.dispose()
                        }
                    }
                }
            }
        }
    }
}

function action1(d, c, b) {
    if (im.getServerName().equals("BMS单机") && im.getServerName().equals("BMS至尊体验服") && !im.getServerName().equals("BMS至尊")) {
        im.playerMessage(1, " 使用环境异常，请还原服务端配置。");
        im.dispose();
        return
    }
    if (status == 0 && d == 0) {
        im.dispose();
        return
    }(d == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            var e = im.getItemId();
            im.gainItem(e, -1);
            im.curNodeEventEnd(true);
            im.eventSKill(0);
            im.setInGameDirectionMode(true, true, true);
            im.inGameDirectionEvent_SetHideEffect(1);
            im.fieldEffect_InsertCanvas(1, 200, 0, 0, 0, 1300, 0);
            im.inGameDirectionEvent_AskAnswerTime(1600)
        } else {
            if (status === a++) {
                im.inGameDirectionEvent_Monologue("人类入侵的次数越来越频繁了。", 0)
            } else {
                if (status === a++) {
                    im.inGameDirectionEvent_Monologue("被人类害死的妖鬼也在日渐增加……我该怎么办……", 1)
                } else {
                    if (status === a++) {
                        im.addPopupSay(9111062, 1000, "如果……我跟他一起并肩作战……结果会不会不一样？", "", 0);
                        im.addNumberForQuestInfo(58819, "letter", 1);
                        im.addNumberForQuestInfo(58710, "2", 3);
                        im.getTopMsgFont("棘鬼记住了你的话。", 3, 20, 8, 0, 0);
                        im.fieldEffect_InsertCanvas(0, 0, 0, 0, 0, 1300, 0);
                        im.inGameDirectionEvent_AskAnswerTime(1600)
                    } else {
                        if (status === a++) {
                            im.eventSKill(0);
                            im.setInGameDirectionMode(false, true, false);
                            im.dispose()
                        }
                    }
                }
            }
        }
    }
}

function action2(d, c, b) {
    if (im.getServerName().equals("BMS单机") && im.getServerName().equals("BMS至尊体验服") && !im.getServerName().equals("BMS至尊")) {
        im.playerMessage(1, " 使用环境异常，请还原服务端配置。");
        im.dispose();
        return
    }
    if (status == 0 && d == 0) {
        im.dispose();
        return
    }(d == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            var e = im.getItemId();
            im.gainItem(e, -1);
            im.curNodeEventEnd(true);
            im.eventSKill(0);
            im.setInGameDirectionMode(true, true, true);
            im.inGameDirectionEvent_SetHideEffect(1);
            im.fieldEffect_InsertCanvas(1, 200, 0, 0, 0, 1300, 0);
            im.inGameDirectionEvent_AskAnswerTime(1600)
        } else {
            if (status === a++) {
                im.inGameDirectionEvent_Monologue("假如，我借用了五行之力，是不是可以把人类彻底赶走？", 0)
            } else {
                if (status === a++) {
                    im.inGameDirectionEvent_Monologue("……希望此事不会对棘鬼造成影响。", 1)
                } else {
                    if (status === a++) {
                        im.addPopupSay(9111062, 1000, "在这种时候居然还在担心我…………", "", 0);
                        im.addNumberForQuestInfo(58819, "letter", 1);
                        im.addNumberForQuestInfo(58710, "2", 3);
                        im.getTopMsgFont("棘鬼记住了你的话。", 3, 20, 8, 0, 0);
                        im.fieldEffect_InsertCanvas(0, 0, 0, 0, 0, 1300, 0);
                        im.inGameDirectionEvent_AskAnswerTime(1600)
                    } else {
                        if (status === a++) {
                            im.eventSKill(0);
                            im.setInGameDirectionMode(false, true, false);
                            im.dispose()
                        }
                    }
                }
            }
        }
    }
};